import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

/**
 * 整型数组合并
 * 将两个整型数组按照升序合并，并且过滤掉重复数组元素。
 * 输出时相邻两数之间没有空格。
 */
public class HJ80 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        TreeSet<Integer> treeSet = new TreeSet<>();
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            for (int i = 0; i < n; i++) {
                treeSet.add(scanner.nextInt());
            }
            int m = scanner.nextInt();
            for (int i = 0; i < m; i++) {
                treeSet.add(scanner.nextInt());
            }

            for (Integer s : treeSet) {
                System.out.print(s);
            }
        }

    }
}
